package com.ds.lens.data.service.dao.sql.provider;

import com.ds.lens.data.service.dao.entity.LensMetricsTags;
import org.apache.ibatis.jdbc.SQL;

public class LensMetricsTagsSqlProvider {

    public String insertSelective(LensMetricsTags record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("lens_metrics_tags");

        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }

        if (record.getAppId() != null) {
            sql.VALUES("app_id", "#{id,jdbcType=BIGINT}");
        }

        if (record.getAppKey() != null) {
            sql.VALUES("app_key", "#{appKey,jdbcType=VARCHAR}");
        }

        if (record.getMetricName()!= null) {
            sql.VALUES("metric_name", "#{metricName,jdbcType=VARCHAR}");
        }

        if (record.getTagKey()!= null) {
            sql.VALUES("tag_key", "#{tagKey,jdbcType=VARCHAR}");
        }

        if (record.getTagValue()!= null) {
            sql.VALUES("tag_value", "#{tagValue,jdbcType=VARCHAR}");
        }

        if (record.getTagFull()!= null) {
            sql.VALUES("tag_full", "#{tagFull,jdbcType=VARCHAR}");
        }


        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LensMetricsTags record) {
        SQL sql = new SQL();
        sql.UPDATE("lens_metrics_tags");

        if (record.getMetricName() != null) {
            sql.SET("metric_name = #{metricName,jdbcType=VARCHAR}");
        }

        if (record.getAppId() != null) {
            sql.SET("app_id = #{appId,jdbcType=BIGINT}");
        }

        if (record.getAppKey() != null) {
            sql.SET("app_key = #{appKey,jdbcType=VARCHAR}");
        }

        if (record.getTagKey()!= null) {
            sql.SET("tag_key = #{tagKey,jdbcType=VARCHAR}");
        }

        if (record.getTagValue()!= null) {
            sql.SET("tag_value = #{tagValue,jdbcType=VARCHAR}");
        }

        if (record.getTagFull()!= null) {
            sql.SET("tag_full = #{tagFull,jdbcType=VARCHAR}");
        }



        sql.WHERE("id = #{id,jdbcType=BIGINT}");

        return sql.toString();
    }
}
